﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using BLL;

public partial class Reg_Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Common.RegJQ(this);
    }


    private Members GetMember()
    {
        Members mb = new Members();
        mb.MemberName = this.txtMemberName.Text.Trim();
        mb.NickName = this.txtNickName.Text.Trim();
        mb.PassWord = Common.MD5(this.txtPwd.Text.Trim()+MembersBll.Sold);
        mb.Sex = rbnMan.Checked;
        mb.City = this.txtCity.Text.Trim();

        return mb;
    }

    private bool Check()
    {
        if (this.txtConfirmPwd.Text.Trim() != this.txtPwd.Text.Trim())
        {
            return false;
        }
        return true;
    }

    protected void btnCreate_Click(object sender, EventArgs e)
    {
        if (!this.Check())
        {
            Library.WebCommon.Alert(this, "两次输入密码不匹配");
            hdnI0sPostBack.Value = "true";
            return;
        }

        if (!this.VerifyImage1.isVerify(this.txtVerify.Text))
        {
            Library.WebCommon.Alert(this, "验证码错误");
            hdnI0sPostBack.Value = "true";
            return;  
        }

        Members mb = this.GetMember();

        MembersBll bl = new MembersBll();
        bool isOK = bl.InsertMemebers(mb);

        if (isOK)
        {
            Library.WebCommon.RegSrcipt(this, "Show()", false);
            return;
        }

        Library.WebCommon.Alert(this, "注册失败");
    }
}
